﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace shenghua.Migrations
{
    public partial class addentity22 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_Comments",
                table: "Comments");

            migrationBuilder.DropColumn(
                name: "Discriminator",
                table: "Comments");

            migrationBuilder.DropColumn(
                name: "OrderEvaluate_RateValue",
                table: "Comments");

            migrationBuilder.RenameTable(
                name: "Comments",
                newName: "OrderEvaluates");

            migrationBuilder.AlterColumn<double>(
                name: "RateValue",
                table: "OrderEvaluates",
                nullable: false,
                oldClrType: typeof(float),
                oldNullable: false);

            migrationBuilder.AddPrimaryKey(
                name: "PK_OrderEvaluates",
                table: "OrderEvaluates",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "ArticleComments",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TargetId = table.Column<int>(nullable: false),
                    UserId = table.Column<long>(nullable: false),
                    UserName = table.Column<string>(nullable: true),
                    UserType = table.Column<string>(nullable: true),
                    ParentCommentId = table.Column<int>(nullable: true),
                    Content = table.Column<string>(nullable: true),
                    Pictures_StringValue = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ArticleComments", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommodityEvaluates",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TargetId = table.Column<int>(nullable: false),
                    UserId = table.Column<long>(nullable: false),
                    UserName = table.Column<string>(nullable: true),
                    UserType = table.Column<string>(nullable: true),
                    ParentCommentId = table.Column<int>(nullable: true),
                    Content = table.Column<string>(nullable: true),
                    Pictures_StringValue = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    RateValue = table.Column<float>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityEvaluates", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ArticleComments");

            migrationBuilder.DropTable(
                name: "CommodityEvaluates");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OrderEvaluates",
                table: "OrderEvaluates");

            migrationBuilder.RenameTable(
                name: "OrderEvaluates",
                newName: "Comments");

            migrationBuilder.AlterColumn<float>(
                name: "RateValue",
                table: "Comments",
                nullable: true,
                oldClrType: typeof(double));

            migrationBuilder.AddColumn<string>(
                name: "Discriminator",
                table: "Comments",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<double>(
                name: "OrderEvaluate_RateValue",
                table: "Comments",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_Comments",
                table: "Comments",
                column: "Id");
        }
    }
}
